﻿using PoemGame.Domain.GameAggregate;
using PoemGame.Domain.PlayerAggregate;
using System;
using System.Linq.Expressions;
using System.Numerics;

namespace PoemGame.Repository.Simple
{
    public class GameRepository : IGameRepository
    {
        private List<Game> _games;

        public GameRepository()
        {
            _games = new List<Game>();
        }
        public Task<Guid> AddAsync(Game game)
        {
            _games.Add(game);
            return Task.FromResult(game.Id);
        }

        public Task<IEnumerable<Game>> GetAllAsync()
        {
            return Task.FromResult(_games as IEnumerable<Game>);
        }

        public Task<Game?> GetAsync(Guid id)
        {
            return Task.FromResult(_games.Find(o => o.Id == id));
        }

        public Task<IEnumerable<Game>> GetByConditionAsync(Expression<Func<Game, bool>> predicate)
        {
            return Task.FromResult(_games.AsQueryable().Where(predicate).ToList() as IEnumerable<Game>);
        }

        public Task RemoveAsync(Game game)
        {
            _games.Remove(game);
            return Task.CompletedTask;
        }

        public Task UpdateAsync(Game game)
        {
            return Task.CompletedTask;

        }
    }
}